package com.kunyi.web.service.file.application.controller;

import com.kunyi.platform.tool.api.JsonResult;
import com.kunyi.web.service.file.entity.req.TemplateSaveReq;
import com.kunyi.web.service.file.entity.resp.ExportProgressResp;
import com.kunyi.web.service.file.service.IExportRequestService;
import com.kunyi.web.service.file.service.IExportTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName ExportController
 * @Description 文件导出-接口
 * @Author pengjunjun
 * @Date 2024/03/04
 * @Version 1.0
 **/
@Slf4j
@Api(tags = "文件导出-接口")
@RestController
@RequestMapping("/export")
public class ExportController {
    @Autowired
    private IExportTemplateService exportTemplateService;
    @Autowired
    private IExportRequestService exportRequestService;

    @ApiOperation("保存模版")
    @PostMapping("/template/save")
    public JsonResult<Long> save(@Validated @RequestBody TemplateSaveReq req) {
        return JsonResult.success(exportTemplateService.save(req));
    }

    @ApiOperation("导出进度查询")
    @GetMapping("/progress/{code}")
    public JsonResult<ExportProgressResp> progress(@PathVariable String code) {
        return JsonResult.success(exportRequestService.progress(code));
    }

}
